package com.erlinyou.im.web.config.session;

import java.util.Map;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.Session;
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.HttpSessionIdResolver;

@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=604800)
@EnableSpringHttpSession
public class SessionConfig {
	public static final Map<String, Session> sessions = new SessionMap<>();
	@Bean
	public HttpSessionIdResolver httpSessionIdResolver() {
		return ParamHttpSessionIdResolver.xAuthToken();
	}
	
//	@Bean
//	public IMSessionRepository mapSessionRepository() {
////		return new MapSessionRepository(sessions);
//		return new IMSessionRepository(sessions);
//	}
	
	
//	@Bean
//	public CookieSerializer cookieSerializer() {
//		DefaultCookieSerializer serializer = new DefaultCookieSerializer();
//		serializer.setCookieName("JSESSIONID"); 
//		serializer.setCookiePath("/"); 
//		serializer.setDomainNamePattern("localhost"); 
//		return serializer;
//	}
}
